home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 December / Australian PC User - December 2003 (CD2).iso / software / apps / files / dwmx2k4.exe / Disk1 / data1.cab / Configuration_En / Objects / Common / Image.js < prev    next >
Encoding:
JavaScript  |  2003-09-05  |  2.6 KB  |  104 lines

  1. // Copyright 2000, 2001, 2002, 2003 Macromedia, Inc. All rights reserved.
  2.  
  3. //---------------     API FUNCTIONS    ---------------
  4.  
  5. function isDOMRequired() { 
  6.     // Return false, indicating that this object is available in code view.
  7.     return false;
  8. }
  9.  
  10. function isAsset() {
  11.     return true;
  12. }
  13.  
  14. function objectTag(assetArgs) {
  15.   var rtnStr = "";
  16.   var bDialogState = dw.getShowDialogsOnInsert(); // Was dialog shown?
  17.   var prefsAccessibilityOption = null;
  18.  
  19.   var newURL;
  20.  
  21. if (dw.appName == "Contribute")
  22. {
  23.     if (MM.insertImgType == "file")
  24.         newURL = dw.doURLEncoding(dw.browseForFileURL("select", "", true, "","","", "", "desktop"));
  25.     else if (MM.insertImgType == "website")
  26.         newURL = dw.doURLEncoding (dw.browseForImage ());
  27. }
  28.  
  29. else
  30. {
  31.   var newURL = dw.doURLEncoding(dw.browseForFileURL("select", "", true));
  32. }
  33.   var imgDim = dw.getNaturalSize(newURL);
  34.  
  35.   if (assetArgs)
  36.   {
  37.       newURL = assetArgs;
  38.     imgDim = dw.getNaturalSize(newURL);
  39.   }
  40.   if ((newURL == '')  && bDialogState) {  return ''; }
  41.  
  42.   if (imgDim){
  43.     rtnStr= '<img src="' + newURL + '" width="' + imgDim[0] +'" height="' + imgDim[1] + '">';
  44.   }else{
  45.     rtnStr= '<img src="' + newURL + '">';
  46.   }    
  47.  
  48.   if (dw.appName == "Contribute")
  49.   {
  50.     prefsAccessibilityOption = dw.getAdminEnforceAccessibilityPref();
  51.   }
  52.   else
  53.   {
  54.     prefsAccessibilityOption = dw.getPreferenceString("Accessibility", "Accessibility Image Options", "");
  55.   }
  56.  
  57.   // the Option is a *string*, not a boolean!
  58.   if (prefsAccessibilityOption == "TRUE")  { rtnStr= addAccessibility(rtnStr);}
  59.  
  60.   var thisDOM = dw.getDocumentDOM();
  61.   if (thisDOM != null)
  62.   {
  63.     var siteName = site.getSiteForURL(dw.getDocumentDOM().URL);
  64.     if( siteName != '' && site.getIsServerSite(siteName) )
  65.     {
  66.         var fullURL;
  67.         if( newURL[0] == "/" )
  68.         fullURL = dw.relativeToAbsoluteURL(dw.getDocumentDOM().URL, dw.getSiteRoot(), newURL);
  69.         else
  70.         fullURL = dw.relativeToAbsoluteURL(dw.getDocumentDOM().URL, "", newURL);
  71.         
  72.         site.get(fullURL);
  73.     }
  74.   }
  75.     
  76.   return rtnStr
  77. }
  78.  
  79. function addAccessibility(rtnStr) {
  80.  
  81.     if (dw.appName == "Contribute")
  82.     {
  83.         var cmdFile = dreamweaver.getConfigurationPath() + "/Commands/ccImageOptions.htm";
  84.     }
  85.     else 
  86.     {
  87.         var cmdFile = dreamweaver.getConfigurationPath() + "/Commands/ImageOptions.htm";
  88.     }
  89.    var cmdDOM = dreamweaver.getDocumentDOM(cmdFile);
  90.    
  91.    cmdDOM.parentWindow.setFormItem(rtnStr);
  92.    if (dw.appName == "Contribute")
  93.    {
  94.     dreamweaver.popupCommand("ccImageOptions.htm");
  95.    }
  96.    else
  97.    {
  98.     dreamweaver.popupCommand("ImageOptions.htm");
  99.     }
  100.    return (cmdDOM.parentWindow.returnAccessibilityStr(rtnStr));    
  101. }
  102.  
  103.  
  104.